#ifndef CPCAPDEV_H
#define CPCAPDEV_H

#include <QObject>
#include <QQmlListProperty>

class CPCapAddr : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString ip READ ip)
    Q_PROPERTY(QString netmask READ netmask)
    Q_PROPERTY(QString broadcast READ broadcast)
    Q_PROPERTY(QString dstaddr READ dstaddr)
public:
    explicit CPCapAddr(QObject *parent = Q_NULLPTR);
    ~CPCapAddr();

    QString ip() const;
    QString netmask() const;
    QString broadcast() const;
    QString dstaddr() const;

    void setIp(const QString &ip);
    void setNetmask(const QString &netmask);
    void setBroadcast(const QString &broadcast);
    void setDstaddr(const QString &dstaddr);

private:
    QString m_ip;
    QString m_netmask;
    QString m_broadcast;
    QString m_dstaddr;
};

class CPCapDev : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString source READ source)
    Q_PROPERTY(QString description READ description)
    Q_PROPERTY(QQmlListProperty<CPCapAddr> addrs READ addrs)
public:
    explicit CPCapDev(QObject *parent = Q_NULLPTR);
    ~CPCapDev();

    QString source() const;
    QString description() const;
    QQmlListProperty<CPCapAddr> addrs();

    void setSource(const QString &source);
    void setDescription(const QString &description);
    void apendAddr(CPCapAddr *addr);

private:
    void clear_addrs();

    QString m_source;
    QString m_description;
    QList<CPCapAddr*> m_addrs;
};

#endif // CPCAPDEV_H
